<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>友情链接</title>
  <link rel="stylesheet" href="../assets/lib/layui/css/layui.css">
  <link rel="stylesheet" href="../assets/lib/cropper/cropper.css">
  <style>
    body {
      height: 100%;
      margin: 20px;
      background-color: #eee;
    }
    .add-btn {
      margin:2px 15px 0;
    }
    .box {
      background-color: #000;
      text-align: center;
    }
    .layui-form-item {
      margin: 15px 25px;
    }
  </style>
</head>
<body>
  <div class="layui-card">
    <div class="layui-card-header">
      <span>友情链接</span>
      <button type="button" class="layui-btn layui-btn-normal layui-layout-right add-btn">添加链接</button>
    </div>
    <div class="layui-card-body">
      <table class="layui-table">
        <colgroup>
          <col width="5%">
          <col width="15%">
          <col width="20%">
          <col width="25%">
          <col width="15%">
          <col width="20%">
        </colgroup>
        <thead>
          <tr>
            <th>ID</th>
            <th>链接图标</th>
            <th>链接名称</th>
            <th>链接地址</th>
            <th>链接描述</th>
            <th>操作</th>
          </tr> 
        </thead>
        <tbody>
        </tbody>
      </table>
    </div>
  </div>
  <!-- 获取 -->
  <script type="text/html" id="tpl-link">
    {{each data item}}
    <tr>
      <td>{{item.id}}</td>
      <td><div class="box"><img src="http://localhost:8888/uploads/{{item.linkicon}}" class="img"></div></td>
      <td>{{item.linkname}}</td>
      <td>{{item. linkurl}}</td>
      <td>{{item.linkdesc}}</td>
      <td>
        <button type="button" class="layui-btn layui-btn-xs" data-id={{item.id}}>编辑</button>
        <button type="button" class="layui-btn  layui-btn-danger layui-btn-xs del" data-id={{item.id}}>删除</button>
      </td>
    </tr>
    {{/each}}
  </script>
  <!-- 添加 -->
  <script type="text/html" id="tpl-add" >
    <form class="layui-form addForm" lay-filter="add-form">
      <!-- 第一行 -->
      <div class="layui-form-item">
        <label class="layui-form-label">链接名称</label>
        <div class="layui-input-block">
          <input type="text"required  lay-verify="required" placeholder="请输入链接名称" autocomplete="off" class="layui-input" name="linkname">
        </div>
      </div>
      <!-- 第二行 -->
      <div class="layui-form-item">
        <label class="layui-form-label">链接地址</label>
        <div class="layui-input-block">
          <input type="text"required  lay-verify="required" placeholder="请输入链接地址" autocomplete="off" class="layui-input" name="linkurl">
        </div>
      </div>
      <!-- 第三行 -->
      <div class="layui-form-item">
        <label class="layui-form-label">链接描述</label>
        <div class="layui-input-block">
          <input type="text"required  lay-verify="required" placeholder="请输入链接描述" autocomplete="off" class="layui-input" name="linkdesc">
        </div>
      </div>
      <!-- 第四行 -->
      <div class="layui-form-item">
        <div class="layui-input-block">
          <button class="layui-btn upbtn" type="button"><i class="layui-icon layui-icon-upload" style="color: #FFF;"></i>上传图片</button>
          <input type="file" class="addfile" name="linkicon" style="display:none">
          <img id="image" src="" style="width: 80px; height: 40px; margin-left: 5px; display:none">
        </div>
      </div>
      <!-- 第五行 -->
      <div class="layui-form-item">
        <div class="layui-input-block">
          <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
          <button type="reset" class="layui-btn layui-btn-primary" id="add-reset">重置</button>
        </div>
      </div>
    <form>
  </script>
  <!-- 编辑 -->
  <script type="text/html" id="tpl-edit" >
    <form class="layui-form editForm" lay-filter="edit-form">
      <!-- 第一行 -->
      <div class="layui-form-item">
        <label class="layui-form-label">链接名称</label>
        <div class="layui-input-block">
          <input type="text"required  lay-verify="required" placeholder="请输入链接名称" autocomplete="off" class="layui-input linkname" name="linkname">
        </div>
      </div>
      <!-- 第二行 -->
      <div class="layui-form-item">
        <label class="layui-form-label">链接地址</label>
        <div class="layui-input-block">
          <input type="text"required  lay-verify="required" placeholder="请输入链接地址" autocomplete="off" class="layui-input linkurl" name="linkurl">
        </div>
      </div>
      <!-- 第三行 -->
      <div class="layui-form-item">
        <label class="layui-form-label">链接描述</label>
        <div class="layui-input-block">
          <input type="text"required  lay-verify="required" placeholder="请输入链接描述" autocomplete="off" class="layui-input linkdesc" name= "linkdesc">
        </div>
      </div>
      <!-- 第四行 -->
      <div class="layui-form-item">
        <div class="layui-input-block">
          <button class="layui-btn editbtn" type="button"><i class="layui-icon layui-icon-upload" style="color: #FFF;"></i>上传图片</button>
          <input type="file" class="editfile" name="linkicon" style="display:none">
          <img id="image" src="" style="width: 80px; height: 40px; margin-left: 5px;">
        </div>
      </div>
      <!-- 第五行 -->
      <div class="layui-form-item">
        <div class="layui-input-block">
          <button class="layui-btn"  lay-submit lay-filter="formDemo">立即提交</button>
          <button type="button" class="layui-btn layui-btn-primary" id="edit-reset">重置</button>
        </div>
      </div>
    <form>
  </script>
  <script src="../assets/lib/jquery.js"></script>
  <script src="../assets/lib/layui/layui.all.js"></script>
  <script src="../assets/lib/jquery.js"></script>
  <script src="../assets/lib/template-web.js"></script>
  <script src="../assets/js/common.js"></script>
  <script src="../assets/js/link/link.js"></script>
</body>
</html>